package com.liang.eight_DeadQueue;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import utils.RabbitmqUtil;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * Created with IntelliJ IDEA.
 * User: XIAOLIANG
 * Date: 2021/6/18
 * Time: 21:44
 * Description: 死信队列 生产者
 */
public class Producer_Dead_Queue {

    //正常的交换机
    public static final String NORMAL_EXCHANGE = "normal_exchange";

    public static void main(String[] args) throws IOException, TimeoutException {

        Channel channel = RabbitmqUtil.getChannel();

        //死信 消息 设置ttl 时间 单位 是ms

        for (int i = 1; i <11; i++) {

            String message = "info"+i;

            AMQP.BasicProperties  properties = new AMQP.BasicProperties().builder().expiration("10000").build();

            channel.basicPublish(NORMAL_EXCHANGE,"zhangsan",properties,message.getBytes("UTF-8"));


        }



    }



}